function verifEnter(e){
	var touche = window.event ? e.keyCode : e.which;
	//alert("touche: "+touche);
	if(touche == 13){
	search('null', 1, 1);
	}	
}

function search(standardFeed, startIndex, pageCour){
  
    var standardFeed = standardFeed;
	var startIndex = startIndex;
	var pageCour = pageCour;

	if(standardFeed == 'null'){
	 	var keywords = document.getElementById("keywords"); 
              
		var order = document.getElementById("order").options[document.getElementById("order").selectedIndex].value; 
		var category = document.getElementById("category").options[document.getElementById("category").selectedIndex].value;
		var adultContent= false;
		if (document.getElementById("adultContent").checked){
		//coch�e
		adultContent = true;
		}
		else{
		//pas coch�e
		adultContent = false;
		}
		var url = "search?keywords="+escape(keywords.value)+"&order="+order+"&category="+category+"&adultContent="+adultContent+"&startIndex="+startIndex+"&pageCour="+pageCour;
	}
	else{
		var url = "search?standardFeed="+standardFeed+"&startIndex="+startIndex+"&pageCour="+pageCour;
	}
	
	//test la connexion avec Mozilla...
        
	if (window.XMLHttpRequest){ 
	      req = new XMLHttpRequest(); 
              
	    } 
	//test la connexion avec IE
	else if (window.ActiveXObject){ 
            
	      req = new ActiveXObject("Microsoft.XMLHTTP"); 
	} 
	 
	req.open("Get",url,true);
         alert("Url : "+url);
    req.onreadystatechange = callback; 
    req.send(null);
    
}

function callback(){ 
    if (req.readyState==4){ 
      if (req.status == 200){ 
      	//si tout reussi bien, je fait:
        var div = document.getElementById('colonnegauche'); 
        var reponseServeur = req.responseText;
        //div.innerHTML = "Client OK!!";  
       // div.innerHTML += "<br/><br/>"; 
        div.innerHTML = reponseServeur; 
        
        //showcontent('head2');
		showcontent('colonnegauche');
		//showcontent('colonnedroite');  
      } 
      else{
      	var div = document.getElementById('colonnegauche'); 
        div.innerHTML = "Erreur dans la requete Ajax"; 
      }
    } 
} 

function visibilite(cid){	
	var targetElement;
	targetElement = document.getElementById(cid);
	if (targetElement.style.display == "none"){
	targetElement.style.display = "block" ;
	}
	else {
	targetElement.style.display = "none" ;
	}
}

function showcontent(cid){
	document.getElementById(cid).style.display = "block";
}

function hidecontent(cid){
	document.getElementById(cid).style.display = "none";
}

function addPanier(nom){
 
	var url = "Panier?video='"+ nom+"'";
	
	//test la connexion avec Mozilla...
	if (window.XMLHttpRequest){ 
	      req = new XMLHttpRequest(); 
	    } 
	//test la connexion avec IE
	else if (window.ActiveXObject){ 
	      req = new ActiveXObject("Microsoft.XMLHTTP"); 
	} 
	req.open("Get",url,true); 
    req.onreadystatechange = callbackPanier; 
    req.send(null);
}

function clean(){
	var url = "Panier?clean='ok'";
	//test la connexion avec Mozilla...
	if (window.XMLHttpRequest){ 
	      req = new XMLHttpRequest(); 
	    } 
	//test la connexion avec IE
	else if (window.ActiveXObject){ 
	      req = new ActiveXObject("Microsoft.XMLHTTP"); 
	}
	req.open("Get",url,true); 
    req.onreadystatechange = callbackPanier; 
    req.send(null);
}

function delPanier(nom){
 
	var url = "Panier?delvideo='"+ nom+"'";
	
	//test la connexion avec Mozilla...
	if (window.XMLHttpRequest){ 
	      req = new XMLHttpRequest(); 
	    } 
	//test la connexion avec IE
	else if (window.ActiveXObject){ 
	      req = new ActiveXObject("Microsoft.XMLHTTP"); 
	}
	req.open("Get",url,true); 
    req.onreadystatechange = callbackPanier; 
    req.send(null);
}


function callbackPanier(){ 
    if (req.readyState==4){ 
      if (req.status == 200){ 
      	var reponseServeur = req.responseText;
      	
      	//si tout reussi bien, je fait:
        var div = document.getElementById('colonnedroite'); 
        //div.innerHTML = "Client OK!!";  
       // div.innerHTML += "<br/><br/>"; 
        div.innerHTML = reponseServeur; 
        
        //
		showcontent('colonnedroite');
      	/*
      	if(reponseServeur.indexOf("##panier",0)!=-1){
      		showcontent('colonnedroite');
      		if(reponseServeur.indexOf("##suggestions",0)==-1){
	      		var code = reponseServeur.substring(8);
	      		var div = document.getElementById('colonnedroite');
	      		div.innerHTML =code;
	      		}
	      	else{
	      	showcontent('head2');
	      	var index = reponseServeur.indexOf("##suggestions",0);
	      	var code = reponseServeur.substring(8,index);
	      	var div = document.getElementById('colonnedroite');
	      	div.innerHTML =code;
	      	var codesugg = reponseServeur.substring(index + 13);
	      	//var div2 = document.getElementById('head2');
	      	//div2.innerHTML =codesugg;
	      	div.innerHTML +=codesugg;
	      	}
      	}*/
     }
      else{
      	var div = document.getElementById('colonnegauche'); 
        div.innerHTML = "Erreur dans la requete Ajax"; 
     }
   }
} 